using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media;

namespace Bookvar.UI
{
    public class ToggleImageButton : ToggleButton
    {
        # region Declarations

        public static readonly DependencyProperty CheckedImageSourceProperty =
                DependencyProperty.Register("CheckedImageSource", typeof (ImageSource), typeof (ToggleImageButton),
                                            new FrameworkPropertyMetadata(null,
                                                                          FrameworkPropertyMetadataOptions.AffectsRender |
                                                                          FrameworkPropertyMetadataOptions.
                                                                              AffectsMeasure));

		public static readonly DependencyProperty CheckedTextProperty =
				DependencyProperty.Register("CheckedText", typeof(string), typeof(ToggleImageButton),
											new FrameworkPropertyMetadata(null,
																		  FrameworkPropertyMetadataOptions.AffectsRender |
																		  FrameworkPropertyMetadataOptions.
																			  AffectsMeasure));

		public static readonly DependencyProperty CheckedTooltipProperty =
				DependencyProperty.Register("CheckedTooltip", typeof(object), typeof(ToggleImageButton),
											new FrameworkPropertyMetadata(null,
																		  FrameworkPropertyMetadataOptions.AffectsRender |
																		  FrameworkPropertyMetadataOptions.
																			  AffectsMeasure |
																		  FrameworkPropertyMetadataOptions.
																			  AffectsArrange));

		public static readonly DependencyProperty UncheckedImageSourceProperty =
				DependencyProperty.Register("UncheckedImageSource", typeof(ImageSource), typeof(ToggleImageButton),
											new FrameworkPropertyMetadata(null,
																		  FrameworkPropertyMetadataOptions.AffectsRender |
																		  FrameworkPropertyMetadataOptions.
																			  AffectsMeasure));

		public static readonly DependencyProperty UncheckedTextProperty =
				DependencyProperty.Register("UncheckedText", typeof(string), typeof(ToggleImageButton),
											new FrameworkPropertyMetadata(null,
																		  FrameworkPropertyMetadataOptions.AffectsRender |
																		  FrameworkPropertyMetadataOptions.
																			  AffectsMeasure));

		public static readonly DependencyProperty UncheckedTooltipProperty =
				DependencyProperty.Register("UncheckedTooltip", typeof(object), typeof(ToggleImageButton),
											new FrameworkPropertyMetadata(null,
																		  FrameworkPropertyMetadataOptions.AffectsRender |
																		  FrameworkPropertyMetadataOptions.
																			  AffectsMeasure |
																		  FrameworkPropertyMetadataOptions.
																			  AffectsArrange));
        public static readonly DependencyProperty CornerRadiusProperty = Border.CornerRadiusProperty.AddOwner(typeof(ToggleImageButton));

        # endregion

        # region Static Constructor

		[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")]
		static ToggleImageButton()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof (ToggleImageButton),
                                                     new FrameworkPropertyMetadata(typeof (ToggleImageButton)));
        }

        # endregion

        public ImageSource CheckedImageSource
        {
            get { return (ImageSource) GetValue(CheckedImageSourceProperty); }
            set { SetValue(CheckedImageSourceProperty, value); }
        }

        public ImageSource UncheckedImageSource
        {
            get { return (ImageSource) GetValue(UncheckedImageSourceProperty); }
            set { SetValue(UncheckedImageSourceProperty, value); }
        }

        public string CheckedText
        {
            get { return (string)GetValue(CheckedTextProperty); }
            set { SetValue(CheckedTextProperty, value); }
        }

        public string UncheckedText
        {
            get { return  (string)GetValue(UncheckedTextProperty); }
            set { SetValue(UncheckedTextProperty, value); }
        }

        public object CheckedTooltip
        {
            get { return GetValue(CheckedTooltipProperty); }
            set { SetValue(CheckedTooltipProperty, value); }
        }

        public object UncheckedTooltip
        {
            get { return GetValue(UncheckedTooltipProperty); }
            set { SetValue(UncheckedTooltipProperty, value); }
        }

        public CornerRadius CornerRadius
        {
            get { return (CornerRadius)GetValue(CornerRadiusProperty); }
            set { SetValue(CornerRadiusProperty, value); }
        }
    }
}